package com.qumitech.visualnovel.controller.rest;


import com.qumitech.visualnovel.component.annotation.RequireWhiteList;
import com.qumitech.visualnovel.model.common.BaseRsp;
import com.qumitech.visualnovel.model.common.ResultEnum;
import com.qumitech.visualnovel.pubdef.dto.location.LocationBlockAdminDTO;
import com.qumitech.visualnovel.pubdef.dto.location.LocationBlockAdminQueryDTO;
import com.qumitech.visualnovel.service.location.LocationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/location")
public class LocationBlockController {

    @Autowired
    private LocationService locationService;

    @PostMapping("/block")
    public BaseRsp saveLocationBlock(@RequestBody LocationBlockAdminDTO adminDTO) {
        locationService.saveLocationBlock(adminDTO);
        return new BaseRsp(ResultEnum.SUCCESS);
    }


    @GetMapping("/block")
    public BaseRsp listLocationBlock(LocationBlockAdminQueryDTO queryDTO) {
        return locationService.listLocationBlock(queryDTO);
    }

    @RequireWhiteList
    @PostMapping("/block/{block_id}")
    public BaseRsp invalidLocationBlock(@PathVariable("block_id") String blockId,
                                @RequestBody LocationBlockAdminDTO adminDTO) {
        adminDTO.setBlockId(blockId);
        locationService.invalidLocationBlock(adminDTO);
        return new BaseRsp(ResultEnum.SUCCESS);
    }

}

